<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="{{url('admin/item')}}" method="get">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <input type="hidden" name="page" value="{{$items->currentPage()}}">
        <input type="hidden" name="orderField" value="{{$request->input('orderField', 'created_at')}}">
        <input type="hidden" name="orderDirection" value="{{$request->input('orderDirection', 'desc')}}">

        <div class="bjui-searchBar">
            <label>类型：</label>
            <select name="type" data-toggle="selectpicker" data-width="80">
                <option value=""></option>
                @foreach($types as $type => $name)
                    <option value="{{$type}}" <?=$request->input('type') == $type ? 'selected' : ''?>>{{$name}}</option>
                @endforeach
            </select>&nbsp;
            <label>分类：</label>
            <select name="p_catalog_id" data-toggle="selectpicker" data-width="80" data-nextselect="#catalog_id"
                    data-refurl="{{url('api/catalog/catalogs')}}?id={value}">
                <option value=""></option>
                @foreach($p_catalogs as $p_catalog)
                    <option value="{{$p_catalog->id}}" <?=$request->input('p_catalog_id') == $p_catalog->id ? 'selected' : ''?>>{{$p_catalog->name}}</option>
                @endforeach
            </select>&nbsp;
            <select name="catalog_id" id="catalog_id" data-toggle="selectpicker" data-width="80">
                <option value=""></option>
                @foreach($catalogs as $catalog)
                    <option value="{{$catalog->id}}" <?=$request->input('catalog_id') == $catalog->id ? 'selected' : ''?>>{{$catalog->name}}</option>
                @endforeach
            </select>&nbsp;
            <label>地点:</label>
            <select name="province_id" data-toggle="selectpicker" data-width="80"
                    data-nextselect="#city_id" data-refurl="{{url('api/area/areas')}}?id={value}">
                <option value=""></option>
                @foreach($provinces as $province)
                    <option value="{{$province->id}}" <?=$request->input('province_id') == $province->id ? 'selected' : ''?>>{{$province->name}}</option>
                @endforeach
            </select>&nbsp;
            <select name="city_id" id="city_id" data-toggle="selectpicker" data-width="80"
                    data-nextselect="#district_id" data-refurl="{{url('api/area/areas')}}?id={value}">
                <option value=""></option>
                @foreach($cities as $city)
                    <option value="{{$city->id}}" <?=$request->input('city_id') == $city->id ? 'selected' : ''?>>{{$city->name}}</option>
                @endforeach
            </select>&nbsp;
            <select name="district_id" id="district_id" data-toggle="selectpicker" data-width="80">
                <option value=""></option>
                @foreach($districts as $district)
                    <option value="{{$district->id}}" <?=$request->input('district_id') == $district->id ? 'selected' : ''?>>{{$district->name}}</option>
                @endforeach
            </select>&nbsp;
            <label>名称：</label><input name="name" size="10" value="{{$request->input('name')}}">
            <button type="submit" class="btn-default" data-icon="search">查询</button>
            &nbsp;
            <a class="btn btn-orange" href="javascript:;" onclick="$(this).navtab('reloadForm', true);"
               data-icon="undo">清空查询</a>
        </div>
    </form>
</div>
<div class="bjui-pageContent">
    <table data-toggle="tablefixed" data-width="100%" data-nowrap="true">
        <thead>
        <tr>
            <th width="40">id</th>
            <th>名称</th>
            <th>类型</th>
            <th>丢失/捡到时间</th>
            <th>用户</th>
            <th>分类</th>
            <th>详细地址</th>
            <th>发布时间</th>
            <th width="80">期望酬金</th>
            <th width="100">状态</th>
            <th width="40">匹配id</th>
            <th width="100">操作</th>
        </tr>
        </thead>
        <tbody>
        @foreach($items as $item)
            <tr data-id="{{$item->id}}">
                <td>{{$item->id}}</td>
                <td>{{$item->name}}</td>
                <td>{{$item->typeName()}}</td>
                <td>{{$item->findLostTime()}}</td>
                <td>{{$item->user->name}}</td>
                <td>{{$item->p_catalog->name . '-' . $item->catalog->name}}</td>
                <td>{{$item->address()}}</td>
                <td>{{$item->created_at}}</td>
                <td>{{$item->wanted_fee}}</td>
                <td>{{$item->status()}}</td>
                <td>@if($matchItem = $item->matchItem()){{$matchItem->id}}@endif</td>
                <td>
                    <a href="{{url('/admin/item/info/' . $item->id)}}" class="btn btn-green" data-toggle="dialog"
                       data-id="item" data-title="查看-{{$item->name}}" data-width="900" data-height="600"
                       data-mask="true">详情</a>
                    @if(!$item->match)
                        <a href="{{url('/admin/item/delete/' . $item->id)}}" class="btn btn-red" data-toggle="doajax"
                           data-type="get" data-confirm-msg="确定要删除该行信息吗？">删除</a>
                    @endif
                </td>
            </tr>
        @endforeach
        </tbody>
    </table>
</div>
<div class="bjui-pageFooter">
    <div class="pages">
        <span>每页{{config('view')['numPerPage']}}条，共 {{$items->total()}} 条</span>
    </div>
    <div class="pagination-box" data-toggle="pagination" data-total="{{$items->total()}}"
         data-page-size="{{config('view')['numPerPage']}}"
         data-page-current="{{$items->currentPage()}}"></div>
</div>